package org.jeecg.modules.api;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.balance.entity.WlhyBalanceIncomeExpance;
import org.jeecg.modules.balance.service.IWlhyBalanceIncomeExpanceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.math.BigDecimal;
import java.util.Arrays;

/**
* @Description: 钱包收支明细表
* @Author: jeecg-boot
* @Date:   2024-04-18
* @Version: V1.0
*/
@Api(tags="钱包收支明细表")
@RestController
@RequestMapping("/finance-api/balance/wlhyBalanceIncomeExpance")
@Slf4j
public class WlhyBalanceIncomeExpanceApi extends JeecgController<WlhyBalanceIncomeExpance, IWlhyBalanceIncomeExpanceService> {
   @Autowired
   private IWlhyBalanceIncomeExpanceService wlhyBalanceIncomeExpanceService;


   /**
    *   充值
    *
    * @param  chargeMode
    * @param  balance
    * @return
    */
   @AutoLog(value = "钱包收支明细表-充值")
   @ApiOperation(value="钱包收支明细表-充值", notes="钱包收支明细表-充值")
   @PostMapping(value = "/charge")
   public Result<JSONObject> charge(@RequestParam BigDecimal balance,
                                    @RequestParam String chargeMode,
                                    @RequestParam String returnUrl
                                    ) {
       JSONObject jsonObject = wlhyBalanceIncomeExpanceService.charge(chargeMode,balance,returnUrl);
       return Result.OK(jsonObject);
   }

 /**
    *   充值回调
    *
    * @return
    */
   @AutoLog(value = "钱包收支明细表-支付宝充值回调")
   @ApiOperation(value="钱包收支明细表-支付宝充值回调", notes="钱包收支明细表-支付宝充值回调")
   @RequestMapping(value = "/balanceChargeNotify")
   public String balanceChargeNotify(HttpServletRequest req) {
       log.info("balanceChargeNotify req {}",req.getParameterMap());
       wlhyBalanceIncomeExpanceService.balanceChargeNotify(req.getParameterMap());
       return "SUCCESS";
   }

}
